<template>
  <div class="page-list-live">
    <PageList>
      <template #header>操作日志</template>
      <template #filter>
        <ListFilter :form="topFilter" @search="handleSearch" @reset="handleReset" />
      </template>
      <template #table>
        <ListTable ref="RefListTable" :loading="tableLoading" :table-data="tableData" :table-col="tableCol" />
      </template>
    </PageList>
  </div>
</template>
<script>
import listMixin from '@/mixins/list'
import ListFilter from '@/components/ListFilter'
import { actionLog } from '@/api/api'
export default {
  components: { ListFilter },
  mixins: [listMixin],
  data() {
    return {
      topFilter: {
        date: { type: 'date', arr: ['createdTime', 'createdTime'] }
      },
      tableData: [],
      tableCol: [
        {
          prop: 'createdTime',
          label: '日期',
          width: '200px',
          formatter: function (row, col, cell) {
            return this.$format(cell, true)
          }.bind(this)
        },
        { prop: 'who', label: '操作账号', width: '100px' },
        { prop: 'content', align: 'left', label: '操作内容' }
      ]
    }
  },
  methods: {
    // 请求列表数据
    async getList(qurey) {
      this.tableLoading = true
      try {
        const obj = qurey || { pageIndex: 1, pageSize: 10, orderBy: 'createdTime', orderByAscent: false }
        const {
          data: { items: resData, count, pageIndex }
        } = await actionLog('post', obj, false)
        this.tableData = []
        this.tableData = resData.map((item) => {
          item.loadingEdit = false
          item.loadingDel = false
          return item
        })
        this.$nextTick(() => {
          this.$refs['RefListTable'].update({ page: pageIndex, count })
          this.tableLoading = false
        })
      } catch (err) {
        this.tableLoading = false
        console.error('getList err: ', err)
      }
    }
  }
}
</script>

<style lang="scss" scoped></style>
